package com.imu.purse.modules.app.dao;

import java.util.List;
import org.apache.ibatis.annotations.Select;
import com.imu.purse.modules.app.entity.CoreEntity;
import com.imu.core.base.BaseMapper;

/**
 * 
 * @author sunhongwei
 * @email sunhongwei@jshijian.com
 * @date 2018-04-16 16:15:31
 * Copyright (c) 2017 武汉极时间科技有限公司 版权所有 
 * Jshijian aloha CO.,LTD. All Rights Reserved. 
 */
public interface CoreMapper extends BaseMapper<CoreEntity>
{
	/**
     * 分页查询
     * @param pageNo 页号
     * @param pageSize 每页显示记录数
     * @return
     */
	@Select({
		"<script>",
		    "SELECT id,",
					"url, ",
					"user_name, ",
					"pwd, ",
					"port, ",
					"domain_name, ",
					"user_create, ",
					"time_create, ",
					"user_update, ",
					"time_update",
		    "FROM imu_core ",
		    "WHERE 1=1",
			"<when test = 'url != null'>",
		    	"AND `url` = #{url}",
		    "</when>",
			"<when test = 'userName != null'>",
		    	"AND `user_name` = #{userName}",
		    "</when>",
			"<when test = 'pwd != null'>",
		    	"AND `pwd` = #{pwd}",
		    "</when>",
			"<when test = 'port != null'>",
		    	"AND `port` = #{port}",
		    "</when>",
			"<when test = 'domainName != null'>",
		    	"AND `domain_name` = #{domainName}",
		    "</when>",
		    "<when test = 'timeUpdate != null'>",
		    	"AND time_create &gt;= #{timeUpdate}",
		    "</when>",
		    "<when test = 'timeCreate != null'>",
				"AND time_create &lt;= #{timeCreate}",
			"</when>",
		    "ORDER BY time_create DESC",
    	"</script>"
	})
    public List<CoreEntity> findByPage(final CoreEntity entity);


	@Select(
		{
			"select url,port,user_name,pwd from imu_core"
		}
	)
	public List<CoreEntity> getCoreAddress();
}
